package com.itheima.web;

import com.itheima.service.ItemService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

@WebServlet("/viewProfileServlet")
public class ViewProfileServlet extends HttpServlet {
    private ItemService service = new ItemService();

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //1. 通过session获取user对象
        HttpSession session = request.getSession();
        Object user = session.getAttribute("user");

        //2. 存入request域中
        request.setAttribute("user", user);

        //3. 转发到user-details.jsp
//        request.getRequestDispatcher("/items.jsp").forward(request,response);
        request.getRequestDispatcher("/user-details.jsp").forward(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request, response);
    }
}
